package com.map.ui;
import android.app.Activity;
import android.os.Bundle;
import android.content.pm.ActivityInfo;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.Toast;

public class BaseActivity extends AppCompatActivity
{

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO: Implement this method

		Toolbar toolbar = new Toolbar(this);
//		setSupportActionBar(toolbar);

		
		if(BaseConfig. themeText.equals("白色"))
		{
			setTheme(R.style.AppTheme_Light);
		}
		else 
		{
			setTheme(R.style.AppTheme);
		}
		
		if(BaseConfig.screen.equals("横屏"))
		{
			BaseConfig. orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
		}
		else if(BaseConfig.screen.equals("竖屏"))
		{
			BaseConfig. orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
		}
		else
		{
			BaseConfig. orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
		}
		setRequestedOrientation(BaseConfig.orientation);
//		setTheme(R.style.AppTheme_Light);
		super.onCreate(savedInstanceState);
	}

	public void toast(String text){
		Toast t = Toast.makeText(this,text,Toast.LENGTH_SHORT);
		t.setText(text);
		t.show();
	}

	@Override
	public boolean onOptionsItemSelected(@NonNull MenuItem item) {
		if(item.getItemId() == android.R.id.home){
			finish();
		}
		return super.onOptionsItemSelected(item);
	}
	
}
